package com.itheiya.controller;


import com.hmall.common.dto.PageDTO;
import com.itheiya.pojo.ItemDoc;
import com.itheiya.pojo.RequestParams;
import com.itheiya.service.ItermIdexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("search")
public class SearchCroller {
    @Autowired
    private ItermIdexService itermIdexService;

    @PostMapping("list")
    public PageDTO<ItemDoc> multipleTermFilter(@RequestBody RequestParams requestParams){
        return itermIdexService.multipleTermFilter(requestParams);

    }


    /**
     * 过滤项集合
     * @param requestParams
     * @return
     */
    @PostMapping("/filters")
    public Map<String,List<String>> searchItemFilters(@RequestBody RequestParams requestParams){
        return itermIdexService.searchItemFilters(requestParams);
    }

    /**
     * 补全
     * @param key
     * @return
     */
    @GetMapping("/suggestion")
    public List<String> findSuggestion(@RequestParam("key")String key){
        return itermIdexService.findSuggestion(key);
    }
}
